home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / HARDWARE.SWG / 0023_Port Info.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  2KB  |  68 lines

  1. {
  2. > Can anybody give me any info on how to read signals from pins on say
  3. > COM2: or from LPT1: or even from The joystick port? I think it has
  4. > been done with the PORT command or something, but what are the values
  5. > to use to read them with? Thanks.
  6.  
  7. You can read in signals from different pins on LPT ports with the PORT
  8. command ( =OUT/IN command in assembler). Just determine the base adress of
  9. the LPT port using
  10. }
  11.  
  12.   LPTadress := MemW[$40 : 6 + LPTNr * 2];
  13.  
  14. {
  15. where LPTNr is the number of the LPT port from 1 to 3.
  16.  
  17. Should return 03BCh, 0378h or 0278h.
  18. That has to be done once at the beginning of the program.
  19. Now you can start to read/write values on this port.
  20. The LPT port has:
  21.  
  22. - 8 data outputs (pin 2 to 9), which can be written using
  23. }
  24.  
  25.   Port[LPTAdress] := B;
  26.  
  27. {
  28. where B is a byte consisting of the 8 bits. Voltage will be 5V for 1, and 0V
  29. for 0. (but not very high power available (TTL/CMOS)
  30.  
  31. - 4 handshake outs which can be written by
  32. }
  33.  
  34.   Port[LPTAdress + 2] := B;
  35.  
  36. {
  37. where B is a byte with the lowest 4 bits set to the values of the pins and
  38. the higher 4 bits always set to zero.
  39.  
  40.         PIN  1: Strobe --> bit 0
  41.         PIN 14: AutoFD --> bit 1
  42.         PIN 16: Init   --> bit 2
  43.         PIN 17: SelIN  --> bit 3
  44.  
  45.         Attention! bit 2/pin 16 is 0V when set to zero, all others
  46.         are INVERTED! (0 --> 5V and vice versa)
  47.  
  48. - 5 handshake inputs which can be read by
  49. }
  50.  
  51.      B := Port[LPTAdress + 1];
  52.  
  53. {
  54.      After the command, B contains the signals that are connected to the
  55.      input pins of the LPT port:
  56.         Bit 0-2: no function
  57.         Bit 3 --> PIN 15/Error
  58.         Bit 4 --> PIN 13/Select
  59.         Bit 5 --> PIN 12/PaperEmpty
  60.         Bit 6 --> PIN 10/Acknowledge
  61.         Bit 7 --> PIN 11/Busy     ===> Attention! This input is INVERSE!
  62.  
  63.  For information: The pins 18 to 25 are Signal Ground pins.
  64.  To use the inputs, connect TTL level 0V for 0, and 5V for 1 to them.
  65.  (Or just use a resistor 10kOhm against +5V (take it from the keyboard
  66.  connector or so, don't know what pin that is :-( and a switch against GND:
  67.  then you can read in the status of the swith: CLOSED: 0, OPEN: 1...)
  68. }